<!DOCTYPE html>
<html >
<head>
	<div th:include="base-libs :: base-libs" ></div>
	<title>新增签约管理</title>
	<style type="text/css">

		.form-table td {
			padding: 1px;
		}

		.form-table input, select {
			width: 100%!important;
		}
		.td-text{
			text-align: right;
			background: #f7f9fb;
			width: 90px;
			vertical-align: middle!important;
			color: #666;
		}
		.td-content{
			vertical-align: middle!important;
		}

		input, select{
			height: 28px!important;
			line-height: 28px!important;
			padding-left: 4px!important;
			box-sizing: border-box!important;
		}
		.panel{
			margin: 4px 2px;
		}
		.panel-header{
			padding: 10px 5px;
			background: #F2F2F2;
		}
		.panel-body{
			padding-bottom: 2px;
		}
		.panel-tool span{
			margin-right: 20px;
			font-weight: bold;
			cursor: pointer;
			color: #2AC672;
		}

		.switchbutton{
			margin-bottom: 2px;
		}
		.switchbutton-on {
			background: #1ea15b;
			color: #fff;
		}

		.jtcyCzDiv{
			vertical-align: middle;
			text-align: center;
			/* width: 80px; */
		}
		.jtcyCzDiv a{
			margin: auto 4px;
			line-height: 28px;
		}
		.panel,.panel-header,.panel-body{
		  	width:100% !important;
		}
	</style>

	<script th:src="'/service/js/jtqy.js'"></script>

	<script th:inline="javascript">
        /**读取request中的初始化数据*/
        var data = [[${data}]];
	</script>
	<script type="text/javascript">
		var zydmCache = {};
		var JTQYINFO = StoreCache.removeCache("JTQYXQINFO");//家庭签约数据
    	var BACKINFO = StoreCache.getCache("BACKINFO");//跳转页面
        $(function() {
            initView()
        	initData();
        });
		/*查询历史记录*/
        function findLsjl(){
            findQyxxLsjl(JTQYINFO.JMXXID);
        }

        function initView(){
            //删除审核按钮(签约/拒绝签约)
            if(JTQYINFO.QYLX != "00"){
                $(".btnSh").remove();
            }
        }

        function initData(){
        	$("body").data("qyxx",JTQYINFO);
        	$("#QYXXID").val(JTQYINFO.QYXXID);
        	var information = qyxxFormatData(JTQYINFO);
			//console.log(information)
        	var timeReg = /^(\d{4}-\d{2}-\d{2})\s+\d{2}:\d{2}:\d{2}/;
            $(".form-control").each(function(){
                var name = $(this).attr("name");
                var value = information[name];
                if(!StringUtils.isEmpty(value)){
                    value = value.replace(timeReg,"$1");
				}
                if($(this).hasClass("isTitle")){
                	$(this).attr("title",value);
                }
                $(this).val(value);
            })
            var jtcy = data.JTCY;
		    if(!StringUtils.isEmpty(jtcy)){
		    	$.each(jtcy,function (index,obj){
		    		JtcyHandler(obj);
		    	})
		    }

		    //签约医生下拉框
			var selectQyys = $("<select id='QYYS_select'>").attr("quick-config","label:'签约医生', validateProxy:'notNull'");
			$("#QYYS").after(selectQyys).remove();
            $.QuickRemote.AjaxJson(contextRoot + "tdgl/queryTdcylbAll", function(result){
                $("#QYYS_select").createOptions(result, {textField: "XM", valueField: "USERID"});
            }, {TDID:JTQYINFO.YLTDID});

        }

    	/** 审核预签约  */
    	function checkYqy(type){
    		var params = {
    			type: type, //agree | noagree
    			QYXXID: JTQYINFO.QYXXID
    		}
    		if(type=='agree'){
                //签约医生
                if(!$("#QYYS_select").QuickValidate()){
                    $("#QYYS_select").css("border","1px solid red").click(function(){
                        $(this).css("border","1px solid #ccc");
					})
                    return;
				}
                /*$.QuickAlert.alertConfirm({
                    content : "确认同意预签约？",
                    callback : function() {
                        $.QuickRemote.AjaxJson("checkYqyData", checkYqyBack, params);
                    }
                })*/

                JTQYINFO.QYTDMC = JTQYINFO.XQYTDMC;  //签约团队名称改为现签约团队名称
                JTQYINFO.FWBIDS = JTQYINFO.FWBID.split(",").join("|");
                StoreCache.setCache("xy_jfMsg",JTQYINFO);//协议_甲方信息

                parent.layer.open({
                    type: 2,
                    area: ["800px", "90%"],
                    content: contextRoot + 'jtqy/changeXy.html',
                    scrollbar: false,
                    resize: false,
                    title:'新协议确定',
                    end: function(){
                        var xyContent = StoreCache.removeCache("xyContent");
                        if(!StringUtils.isEmpty(xyContent)){
                            var XYH = StoreCache.removeCache("XYH");
                            var USID = $("#QYYS_select").val();
                            params.USID = USID;
                            var addXy = {
                                CONTENT: xyContent,XYH:XYH,JMXXID:JTQYINFO.JMXXID,QYXXID:JTQYINFO.QYXXID,
                                TDID:JTQYINFO.YLTDID,TDMC:JTQYINFO.TDMC,YSID:USID,YSXM:$("#QYYS_select option:selected").text()
							};
                            params.addXy = JSON.stringify(addXy);
                            $.QuickRemote.AjaxJson("checkYqyData", checkYqyBack, params);
                        }
                    }
                });
    		}else{
                $("#QYYS_select").css("border","1px solid #ccc");
	    		$.QuickAlert.alertConfirm({
	    			content : "确认拒绝预签约？",
	    			callback : function() {
	    				$.QuickRemote.AjaxJson("checkYqyData", checkYqyBack, params);
	    			}
	    		})
    		}
    	}
    	
    	/** 审核预签约 - 回调  */
    	function checkYqyBack(result){
    		if(result.state=='true'){
				$.QuickAlert.alertNormal(result.info, {callback: function(){
					//parent.selectMenuByHand('预签约');
					btnBackHandler();
				}});
			}else{
				$.QuickAlert.alertFail({content: result.info});
			}
    	}

        /**返回回调*/
        function btnBackHandler()
        {
            //$.QuickUrlUtils.redirectUrl(BACKINFO);
            location = BACKINFO;
        }
	</script>
</head>
<body class="easyui-layout" >
	<div region="north" style="height: 41px; border: none; overflow: hidden; background-color: #f9f9f9;">
		<div class="title">
			<h3>签约详情</h3>
		</div>
	</div>
	<div region="center" style="overflow-x: hidden; border: none;">
			<div th:include="common/qyxqModelEasy :: qyxqModelEasy"></div>
	</div>
	<div region="south" style="height: 41px; border: none; background-color: #f9f9f9; padding-top: 6px; text-align: center;">
		<button class="btn btn-info btnSh" type="button" onclick="checkYqy('agree')">签约</button>
		<button class="btn btn-info btnSh" type="button" onclick="checkYqy('noagree')">拒绝签约</button>
		<button class="btn btn-info" type="button" onclick="btnBackHandler()">返回</button>
	</div>
</body>

<script type="text/html" id="cyxxTr">
	<tr class="cyxxTr">
		<td class="td-text">
			<label>身份证号：</label>
		</td>
		<td class="td-content" style="width: 160px;">
			<input type="text" autocomplete="off" name="SFZH" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-text">
			<label>成员姓名：</label>
		</td>
		<td class="td-content" style="width: 120px;">
			<input type="text" autocomplete="off" name="XM" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-text">
			<label>成员关系：</label>
		</td>
		<td class="td-content" style="width: 160px;">
			<input type="text" autocomplete="off" name="XMMC" readonly="readonly" 
				   class="form-control">
		</td>
		<td class="td-content" style="min-width: 210px;">
			<input type="text" readonly="readonly" name="QYXX" autocomplete="off"
				   class="form-control isTitle" onmouseover="this.title=this.value">
		</td>
		<td>
			<div class="jtcyCzDiv">
				<input name="RYSX" class="form-control" hidden="hidden" >
				<a class="jtcyBtn" action="remove">移除</a>
				<!-- <button class="btn btn-info jtcyBtn" type="button" action="remove">移除</button> -->
			</div>
		</td>
	</tr>
</script>
</html>
